package smartwiz.client.app.mvp.home;

import java.util.ArrayList;

import smartwiz.client.fwk.BaseView;
import smartwiz.client.fwk.SlidingPanel;
import smartwiz.client.fwk.widgets.Hyperlink;
import smartwiz.shared.Apartment;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.RequiresResize;
import com.google.gwt.user.client.ui.Widget;

public class HomeView extends BaseView<HomeMVP.Presenter> implements HomeMVP.View, RequiresResize {

	private static HomeViewUiBinder uiBinder = GWT
			.create(HomeViewUiBinder.class);

	interface HomeViewUiBinder extends UiBinder<Widget, HomeView> {
	}
    @UiField
    Image leftButton;
    @UiField
    Image rightButton;
	@UiField
	SlidingPanel slider;
	@UiField(provided=true)
	Hyperlink adminLink;
	
	public HomeView() {
		adminLink = new Hyperlink("Admin", new ClickHandler() {
			
			public void onClick(ClickEvent event) {
				presenter.onAdminLink();
			}
		});
		initWidget(uiBinder.createAndBindUi(this));
		leftButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
            	slider.showPreviousWidget();
            }
        });
        rightButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
            	slider.showNextWidget();
            }
        });
		slider.add(new Image("images/apartman.jpg"));
		slider.add(new Image("images/apartman2.gif"));
	}

	public void onResize() {
		
	}

	public void setApartments(ArrayList<Apartment> list) {
		Window.alert(list+"");
		if(list != null){
			
			//clear list slider.clear();
			
			for (Apartment apartment : list) {
				slider.add(new Image(apartment.getImage()));
			}
		}
	}


}
